package com.nt.test.controller;

import com.nt.test.entity.User;
import com.nt.test.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Controller
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping(value="/register",method = RequestMethod.POST)
    public int userRegister(@RequestBody User user) {
        return userService.createUser(user);
    };

    @RequestMapping(value="/login", method = RequestMethod.POST)
    public User userLogin(@RequestBody User user) {
        return userService.selectUser(user);
    };

    @RequestMapping(value="/hello",method = RequestMethod.GET)
    public List<User> index(@RequestParam ("username")String username){
        return userService.findByUsername(username);
    };
}
